﻿// <copyright file="ChartDateTimeScaleTest.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2008 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2008-12-25</date>
// <summary>WPF OpenWPFChart library. ChartDateTimeScale class Test.</summary>
// <revision>$Id$</revision>

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenWPFChart.Parts;

namespace Tests
{
    /// <summary>
    /// This is a test class for ChartDateTimeScaleTest and is intended
    /// to contain all ChartDateTimeScaleTest Unit Tests
    ///</summary>
	[TestClass()]
	public class ChartDateTimeScaleTest
	{
		#region TestContext
		private TestContext testContextInstance;
		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}
		#endregion TestContext

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion

		#region Constructor Tests
		/// <summary>
		/// A test for parametrizied constructor
		///</summary>
		[TestMethod()]
		public void ConstructorTest()
		{
			ConstructorTestTicksScale();
			ConstructorTestMillisecondsScale();
			ConstructorTestSecondsScale();
			ConstructorTestMinutesScale();
			ConstructorTestHoursScale();
			ConstructorTestDaysScale();
			ConstructorTestWeeksScale();
			ConstructorTestMonthsScale();
			ConstructorTestYearsScale();
		}

		void ConstructorTestTicksScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(100)
				, new DateTime(200), 300);
			Assert.AreEqual(DateTimeTickUnits.Ticks, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
			
			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(200)
				, new DateTime(100), 300);
			Assert.AreEqual(DateTimeTickUnits.Ticks, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
		}

		void ConstructorTestMillisecondsScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 1, 1, 0, 0, 0, 15), 300);
			Assert.AreEqual(DateTimeTickUnits.Milliseconds, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
			
			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 1, 1, 0, 0, 0, 15)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Milliseconds, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
		}

		void ConstructorTestSecondsScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 1, 1, 0, 0, 15), 300);
			Assert.AreEqual(DateTimeTickUnits.Seconds, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 1, 1, 0, 0, 15)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Seconds, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
		}

		void ConstructorTestMinutesScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 1, 1, 0, 15, 0), 300);
			Assert.AreEqual(DateTimeTickUnits.Minutes, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 1, 1, 0, 15, 0)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Minutes, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
		}

		void ConstructorTestHoursScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 1, 1, 12, 0, 0), 300);
			Assert.AreEqual(DateTimeTickUnits.Hours, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 1, 1, 12, 0, 0)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Hours, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual);
		}

		void ConstructorTestDaysScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 1, 15), 300);
			Assert.AreEqual(DateTimeTickUnits.Days, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300.0, actual, 10e-10);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 1, 15)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Days, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300.0, actual, 10e-10);
		}

		void ConstructorTestWeeksScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2008, 3, 15), 300);
			Assert.AreEqual(DateTimeTickUnits.Weeks, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2008, 3, 15)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Weeks, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);
		}

		void ConstructorTestMonthsScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2009, 12, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Months, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2009, 12, 1)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Months, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);
		}

		void ConstructorTestYearsScale()
		{
			// Start < Stop
			ChartDateTimeScale target = new ChartDateTimeScale(new DateTime(2008, 1, 1)
				, new DateTime(2019, 12, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Years, target.TickUnits);
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);

			// Start > Stop
			target = new ChartDateTimeScale(new DateTime(2019, 12, 1)
				, new DateTime(2008, 1, 1), 300);
			Assert.AreEqual(DateTimeTickUnits.Years, target.TickUnits);
			actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
			actual = target.ToPixels(target.Stop);
			Assert.AreEqual(300, actual, 10e-10);
		}
		#endregion Constructor Tests

		#region nearestLongTick Tests
		/// <summary>
		/// A test for nearestLongTick with TickUnits = DateTimeTickUnits.Months
		///</summary>
		[TestMethod()]
		[DeploymentItem("OpenWPFChart.Parts.dll")]
		public void nearestLongTickTest()
		{
			nearestLongTickTestInMonths();
			nearestLongTickTestInDays();
		}

		#region nearestLongTickTestInMonths
		/// <summary>
		/// A test for nearestLongTick with TickUnits = DateTimeTickUnits.Months
		///</summary>
		private void nearestLongTickTestInMonths()
		{
			ChartDateTimeScale_Accessor target = new ChartDateTimeScale_Accessor()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2009, 12, 1),
				TickUnits = DateTimeTickUnits.Months,
				TickStep = 1,
				LongTickRate = 3
			};

			#region TickStep == 1, LongTickRate = 3
			// Test with default LongTickAnchor = DateTime.MinValue (01-01-01 12:00:00 AM)
			DateTime expected = new DateTime(2008, 1, 1);
			DateTime actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start
			target.LongTickAnchor = (DateTime)target.Start;
			expected = new DateTime(2008, 1, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Stop
			target.LongTickAnchor = (DateTime)target.Stop;
			expected = new DateTime(2007, 12, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start - 2 month
			target.LongTickAnchor = new DateTime(2007, 11, 1);
			expected = new DateTime(2007, 11, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start - LongTickRate months
			target.LongTickAnchor = new DateTime(2007, 10, 1);
			expected = new DateTime(2008, 1, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start + 1 month
			target.LongTickAnchor = ((DateTime)target.Start).AddMonths(1);
			expected = new DateTime(2007, 11, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);
			#endregion TickStep == 1, LongTickRate = 3
		}
		#endregion nearestLongTickTestInMonths

		#region nearestLongTickTestInDays
		/// <summary>
		/// Tests for nearestLongTick with TickUnits = DateTimeTickUnits.Days
		///</summary>
		private void nearestLongTickTestInDays()
		{
			nearestLongTickTestInDaysStartLtStop();
			nearestLongTickTestInDaysStartGtStop();
		}

		/// <summary>
		/// A test for nearestLongTick with TickUnits = DateTimeTickUnits.Days.
		/// Start &lt; Stop
		///</summary>
		private void nearestLongTickTestInDaysStartLtStop()
		{
			ChartDateTimeScale_Accessor target = new ChartDateTimeScale_Accessor()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2008, 1, 31),
				TickUnits = DateTimeTickUnits.Days,
				TickStep = 1,
				LongTickRate = 10
			};
			
			#region TickStep == 1, LongTickRate = 10
			// Test with default LongTickAnchor = DateTime.MinValue (01-01-01 12:00:00 AM)
			DateTime expected = new DateTime(2007, 12, 30);
			DateTime actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start
			target.LongTickAnchor = new DateTime(2008, 1, 1);
			expected = new DateTime(2008, 1, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Stop
			target.LongTickAnchor = new DateTime(2008, 1, 31);
			expected = new DateTime(2008, 1, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start - 2 daws
			target.LongTickAnchor = new DateTime(2007, 12, 30);
			expected = new DateTime(2007, 12, 30);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start - LongTickRate days
			target.LongTickAnchor = new DateTime(2007, 12, 22);
			expected = new DateTime(2008, 1, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start + 1 day
			target.LongTickAnchor = new DateTime(2008, 1, 2);
			expected = new DateTime(2007, 12, 23);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);
			#endregion TickStep == 1, LongTickRate = 10
		}

		/// <summary>
		/// A test for nearestLongTick with TickUnits = DateTimeTickUnits.Days.
		/// Start &gt; Stop
		///</summary>
		private void nearestLongTickTestInDaysStartGtStop()
		{
			ChartDateTimeScale_Accessor target = new ChartDateTimeScale_Accessor()
			{
				Start = new DateTime(2008, 1, 31),
				Stop = new DateTime(2008, 1, 1),
				TickUnits = DateTimeTickUnits.Days,
				TickStep = 1,
				LongTickRate = 10
			};
			
			#region TickStep == 1, LongTickRate = 10
			// Test with default LongTickAnchor = DateTime.MinValue (01-01-01 12:00:00 AM)
			DateTime expected = new DateTime(2008, 2, 8);
			DateTime actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start
			target.LongTickAnchor = (DateTime)target.Start;
			actual = target.nearestLongTick();
			Assert.AreEqual(target.Start, actual);

			// Test with LongTickAnchor = Stop
			target.LongTickAnchor = (DateTime)target.Stop;
			actual = target.nearestLongTick();
			Assert.AreEqual(target.Start, actual);

			// Test with LongTickAnchor = Start - 2 daws
			target.LongTickAnchor = new DateTime(2008, 1, 29);
			expected = new DateTime(2008, 2, 8);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start + 1 day
			target.LongTickAnchor = new DateTime(2008, 2, 1);
			expected = new DateTime(2008, 2, 1);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Start + 10 day
			target.LongTickAnchor = new DateTime(2008, 2, 10);
			expected = new DateTime(2008, 1, 31);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);

			// Test with LongTickAnchor = Stop - 2 day
			target.LongTickAnchor = new DateTime(2007, 12, 30);
			expected = new DateTime(2008, 2, 8);
			actual = target.nearestLongTick();
			Assert.AreEqual(expected, actual);
			#endregion TickStep == 1, LongTickRate = 10
		}
		#endregion nearestLongTickTestInDays
		#endregion nearestLongTick Tests

		/// <summary>
		///A test for Ticks
		///</summary>
		[TestMethod()]
		public void TicksTest()
		{
			ChartDateTimeScale target = new ChartDateTimeScale()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2008, 12, 1),
				TickUnits = DateTimeTickUnits.Months,
				LongTickAnchor = new DateTime(2008, 1, 1),
				LongTickRate = 12
			};

			#region TickUnits = DateTimeTickUnits.Months
			// Test with LongTickAnchor = Start
			List<ScaleTick> expected = new List<ScaleTick>()
			{
				new ScaleTick(new DateTime(2008, 1, 1), true),
				new ScaleTick(new DateTime(2008, 2, 1), false),
				new ScaleTick(new DateTime(2008, 3, 1), false),
				new ScaleTick(new DateTime(2008, 4, 1), false),
				new ScaleTick(new DateTime(2008, 5, 1), false),
				new ScaleTick(new DateTime(2008, 6, 1), false),
				new ScaleTick(new DateTime(2008, 7, 1), false),
				new ScaleTick(new DateTime(2008, 8, 1), false),
				new ScaleTick(new DateTime(2008, 9, 1), false),
				new ScaleTick(new DateTime(2008, 10, 1), false),
				new ScaleTick(new DateTime(2008, 11, 1), false),
				new ScaleTick(new DateTime(2008, 12, 1), false),
			};
			List<ScaleTick> actual = target.Ticks().ToList();
			CollectionAssert.AreEqual(expected, actual);
			#endregion TickUnits = DateTimeTickUnits.Months

			#region TickUnits = DateTimeTickUnits.Days
			target = new ChartDateTimeScale()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2008, 1, 31),
				TickUnits = DateTimeTickUnits.Days,
				LongTickAnchor = new DateTime(2008, 1, 1),
				LongTickRate = 10
			};

			// Test with LongTickAnchor = Start
			expected = new List<ScaleTick>()
			{
				new ScaleTick(new DateTime(2008, 1, 1), true),
				new ScaleTick(new DateTime(2008, 1, 2), false),
				new ScaleTick(new DateTime(2008, 1, 3), false),
				new ScaleTick(new DateTime(2008, 1, 4), false),
				new ScaleTick(new DateTime(2008, 1, 5), false),
				new ScaleTick(new DateTime(2008, 1, 6), false),
				new ScaleTick(new DateTime(2008, 1, 7), false),
				new ScaleTick(new DateTime(2008, 1, 8), false),
				new ScaleTick(new DateTime(2008, 1, 9), false),
				new ScaleTick(new DateTime(2008, 1, 10), false),
				new ScaleTick(new DateTime(2008, 1, 11), true),
				new ScaleTick(new DateTime(2008, 1, 12), false),
				new ScaleTick(new DateTime(2008, 1, 13), false),
				new ScaleTick(new DateTime(2008, 1, 14), false),
				new ScaleTick(new DateTime(2008, 1, 15), false),
				new ScaleTick(new DateTime(2008, 1, 16), false),
				new ScaleTick(new DateTime(2008, 1, 17), false),
				new ScaleTick(new DateTime(2008, 1, 18), false),
				new ScaleTick(new DateTime(2008, 1, 19), false),
				new ScaleTick(new DateTime(2008, 1, 20), false),
				new ScaleTick(new DateTime(2008, 1, 21), true),
				new ScaleTick(new DateTime(2008, 1, 22), false),
				new ScaleTick(new DateTime(2008, 1, 23), false),
				new ScaleTick(new DateTime(2008, 1, 24), false),
				new ScaleTick(new DateTime(2008, 1, 25), false),
				new ScaleTick(new DateTime(2008, 1, 26), false),
				new ScaleTick(new DateTime(2008, 1, 27), false),
				new ScaleTick(new DateTime(2008, 1, 28), false),
				new ScaleTick(new DateTime(2008, 1, 29), false),
				new ScaleTick(new DateTime(2008, 1, 30), false),
				new ScaleTick(new DateTime(2008, 1, 31), true),
			};
			actual = target.Ticks().ToList();
			CollectionAssert.AreEqual(expected, actual);
			#endregion TickUnits = DateTimeTickUnits.Days
		}

		/// <summary>
		///A test for PrevTick with TickUnits = DateTimeTickUnits.Days
		///</summary>
		[TestMethod()]
		[DeploymentItem("OpenWPFChart.Parts.dll")]
		public void PrevTickTest()
		{
			#region In Years
			DateTime actual = ChartDateTimeScale_Accessor.PrevTick(new DateTime(2008, 1, 1), 1, DateTimeTickUnits.Years);
			Assert.AreEqual(new DateTime(2007, 1, 1), actual);
			#endregion In Years

			#region In Months
			actual = ChartDateTimeScale_Accessor.PrevTick(new DateTime(2008, 1, 1), 1, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2007, 12, 1), actual);
			
			actual = ChartDateTimeScale_Accessor.PrevTick(new DateTime(2008, 1, 1), 12, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2007, 1, 1), actual);
			
			actual = ChartDateTimeScale_Accessor.PrevTick(new DateTime(2008, 1, 1), 13, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2006, 12, 1), actual);
			#endregion In Months

			#region In Days
			actual = ChartDateTimeScale_Accessor.PrevTick(new DateTime(2008, 1, 1), 1, DateTimeTickUnits.Days);
			Assert.AreEqual(new DateTime(2007, 12, 31), actual);
			#endregion In Days
		}

		/// <summary>
		///A test for NextTick
		///</summary>
		[TestMethod()]
		[DeploymentItem("OpenWPFChart.Parts.dll")]
		public void NextTickTest()
		{
			#region In Years
			DateTime actual = ChartDateTimeScale_Accessor.NextTick(new DateTime(2008, 1, 1), 1, DateTimeTickUnits.Years);
			Assert.AreEqual(new DateTime(2009, 1, 1), actual);
			#endregion In Years

			#region In Months
			actual = ChartDateTimeScale_Accessor.NextTick(new DateTime(2007, 12, 1), 1, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2008, 1, 1), actual);

			actual = ChartDateTimeScale_Accessor.NextTick(new DateTime(2008, 1, 1), 12, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2009, 1, 1), actual);

			actual = ChartDateTimeScale_Accessor.NextTick(new DateTime(2008, 1, 1), 13, DateTimeTickUnits.Months);
			Assert.AreEqual(new DateTime(2009, 2, 1), actual);
			#endregion In Months

			#region In Days
			actual = ChartDateTimeScale_Accessor.NextTick(new DateTime(2007, 12, 31), 1, DateTimeTickUnits.Days);
			Assert.AreEqual(new DateTime(2008, 1, 1), actual);
			#endregion In Days
		}

		/// <summary>
		///A test for ToPixels
		///</summary>
		[TestMethod()]
		public void ToPixelsTest()
		{
			ChartDateTimeScale target = new ChartDateTimeScale()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2009, 12, 1),
				TickUnits = DateTimeTickUnits.Months,
			};
			double actual = target.ToPixels(target.Start);
			Assert.AreEqual(0.0, actual);
		}

		/// <summary>
		///A test for FromPixels
		///</summary>
		[TestMethod()]
		public void FromPixelsTest()
		{
			ChartDateTimeScale target = new ChartDateTimeScale()
			{
				Start = new DateTime(2008, 1, 1),
				Stop = new DateTime(2009, 12, 1),
				TickUnits = DateTimeTickUnits.Months,
			};
			DateTime actual = (DateTime)target.FromPixels(0.0);
			Assert.AreEqual(target.Start, actual);
		}
	}
}
